﻿using UnityEngine;
using System.Collections;
using Holoville.HOTween;

namespace MiniGameTrash
{
    public class TrashScript : MonoBehaviour
    {
        public GameObject gameManager;
        public string methodName;
        public int param; // 1 for organic, -1 for non-organic
        public int scoreAddition;

        // Use this for initialization
        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {

        }

        void OnTriggerEnter2D(Collider2D collider)
        {
            HOTween.To(transform, 0.2f, new TweenParms()
                    .Prop("localScale", new Vector3(1.3f, 1.3f)));

            HOTween.To(transform, 0.2f, new TweenParms()
                    .Prop("localScale", new Vector3(1f, 1f, 1f))
                    .Delay(0.2f));

            if (collider.tag == "Sampah Organik")
            {
                gameManager.SendMessage(methodName, (param * scoreAddition), SendMessageOptions.DontRequireReceiver);
            }

            if (collider.tag == "Sampah NonOrganik")
            {
                gameManager.SendMessage(methodName, (param * -1 * scoreAddition), SendMessageOptions.DontRequireReceiver);
            }
        }
    }
}